const http = require("../../moudles/http")
Page({
    data:{
        arr:"",
        playStates:{}   /* 存所有item播放的状态 */
    },
    handleSubmit(event){
        // console.log(event.detail.value.keyword)
        http({
            keyword:event.detail.value.keyword,
            success:res=>{
                var arr = res.data.result.albums
                this.setData({
                    arr
                })
            }
        })
    },
    handleMusic(event){
        let id = event.currentTarget.dataset.id
        let playStates = this.data.playStates
        playStates[id] = !playStates[id]
        for(let key in playStates){
            if(key != id){
                playStates[key]=false
            }
        }
        // console.log(playStates);
        this.setData({
            playStates
        })
    },
    handleClick(event){
        let {id} = event.currentTarget.dataset;
        // 实现跳转
        wx.navigateTo({
            url: `/pages/detail/detail?id=${id}`
        })
    }
})
